package 美国疫情;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.lib.db.DBWritable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class MysqlBean implements DBWritable, Writable {
    private String date;
    private String stats;
    private String fips;
    private int cases;
    private int deaths;

    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(date);
        dataOutput.writeUTF(stats);
        dataOutput.writeUTF(fips);
        dataOutput.writeInt(cases);
        dataOutput.writeInt(deaths);
    }

    public void readFields(DataInput dataInput) throws IOException {
        date = dataInput.readUTF();
        stats = dataInput.readUTF();
        fips = dataInput.readUTF();
        cases = dataInput.readInt();
        deaths = dataInput.readInt();
    }

    public void write(PreparedStatement statement) throws SQLException {
        statement.setString(1, date);
        statement.setString(2, stats);
        statement.setString(3, fips);
        statement.setInt(4, cases);
        statement.setInt(5, deaths);
    }

    public void readFields(ResultSet resultSet) throws SQLException {
        date = resultSet.getString(1);
        stats = resultSet.getString(2);
        fips = resultSet.getString(3);
        cases = resultSet.getInt(4);
        deaths = resultSet.getInt(5);
    }

    public void set(String date, String stats, String fips, int cases, int deaths) {
        this.date = date;
        this.stats = stats;
        this.fips = fips;
        this.cases = cases;
        this.deaths = deaths;
    }

    @Override
    public String toString() {
        return "MysqlBean{" +
                "date='" + date + '\'' +
                ", stats='" + stats + '\'' +
                ", fips='" + fips + '\'' +
                ", cases=" + cases +
                ", deaths=" + deaths +
                '}';
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }


    public String getStats() {
        return stats;
    }

    public void setStats(String stats) {
        this.stats = stats;
    }

    public String getFips() {
        return fips;
    }

    public void setFips(String fips) {
        this.fips = fips;
    }

    public int getCases() {
        return cases;
    }

    public void setCases(int cases) {
        this.cases = cases;
    }

    public int getDeaths() {
        return deaths;
    }

    public void setDeaths(int deaths) {
        this.deaths = deaths;
    }
}
